package org.jackysoft.interceptor;

import java.lang.reflect.Method;

import org.jackysoft.entity.Identifiable;

import com.opensymphony.xwork2.ActionInvocation;

public class UpdateInterceptor extends AbstractInterceptor {

	/**
	 * 
	 */
	private static final long serialVersionUID = -451811091316864794L;

	@Override
	public String intercept(ActionInvocation arg0) throws Exception {
		String rst = super.intercept(arg0);
		
		if(VALIDATED.equals(rst)){
			return VALIDATED;
		}
					
		Method serviceUpdateBean = service.getClass().getMethod("update", Identifiable.class);
		
		serviceUpdateBean.invoke(service, bean);
		
		return arg0.invoke();
	}

}
